
                    <p><span style="color:#fe2c24;">注意事项：考试的时候在编程题考试系统里面需要上传身份证照片，然后在系统里面打开摄像头审核是否本人，最后考试，考试全程都开启摄像头，但是可以切屏，不限次数！</span></p> 
<p><span style="color:#fe2c24;">（如果身份证跟本人在系统里面审核失败的话，记得将当</span><span style="color:#fe2c24;">前身份证照片不要露边，除了身份证，照片边上什么都不要有）</span></p> 
<p><span style="color:#fe2c24;">更新时间：2024年12月11日</span></p> 
<p><span style="color:#fe2c24;">大家根据本套题库考过的话，可以给作者打赏一瓶饮料哈哈，题库来之不易！（不强制）</span></p> 
<h2 id="%E7%BC%96%E7%A8%8B%E9%A2%98"><a name="t0"></a><span style="color:#0d0016;">编程题</span></h2> 
<p></p> 
<h3 id="1%E3%80%81%E8%BF%9E%E7%BB%AD%E6%95%B4%E6%95%B0%E4%B9%8B%E5%92%8C"><a name="t1"></a><span style="color:#0d0016;">连续整数之和</span></h3> 
<p></p> 
<h4><a name="t2"></a><span style="color:#0d0016;">题目</span></h4> 
<p></p> 
<p><img alt="" height="1200" src="https://i-blog.csdnimg.cn/direct/9ffb89b0ae1e4242a869cf7a56a3dff6.png" width="1200"></p> 
<p></p> 
<h4><a name="t3"></a>答案</h4> 
<pre data-index="0" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    <span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">'\n'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    let n <span class="hljs-operator">=</span> parseInt(inputArray[<span class="hljs-number">0</span>].trim(), <span class="hljs-number">10</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    <span class="hljs-keyword">function</span> doFunc() {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        <span class="hljs-keyword">for</span> (let m <span class="hljs-operator">=</span> <span class="hljs-number">2</span>; m <span class="hljs-operator">*</span> (m<span class="hljs-operator"> - </span><span class="hljs-number">1</span>) <span class="hljs-operator">/</span> <span class="hljs-number">2</span> <span class="hljs-operator">&lt;</span> n; m<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">            <span class="hljs-keyword">if</span> ((n<span class="hljs-operator"> - </span>m <span class="hljs-operator">*</span> (m<span class="hljs-operator"> - </span><span class="hljs-number">1</span>) <span class="hljs-operator">/</span> <span class="hljs-number">2</span>) % m <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">0</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">                console.log(<span class="hljs-string">"YES"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">                <span class="hljs-keyword">return</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">            }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        console.log(<span class="hljs-string">"NO"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    doFunc();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:0,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:0,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<p></p> 
<h3 id="2%E3%80%81%E9%87%8D%E5%A4%8D%E5%AD%97%E6%AF%8D%E8%BF%9E%E7%BB%AD%E5%87%BA%E7%8E%B0%E6%AC%A1%E6%95%B0"><a name="t4"></a><span style="color:#0d0016;">重复字母连续出现次数</span></h3> 
<p></p> 
<h4><a name="t5"></a>题目</h4> 
<h3 id="%E2%80%8B%E7%BC%96%E8%BE%91"><a name="t6"></a><img alt="" height="473" src="https://i-blog.csdnimg.cn/direct/5662a867bc9042faa70df0cff1c56b1c.png" width="1191"></h3> 
<h3><a name="t7"></a></h3> 
<h4><a name="t8"></a>答案</h4> 
<pre data-index="1" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    <span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">'\n'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    let str <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">0</span>].trim();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    <span class="hljs-keyword">function</span> doFunc() {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        let maxCount <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        let currentCount <span class="hljs-operator">=</span> <span class="hljs-number">1</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        <span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">1</span>; i <span class="hljs-operator">&lt;</span> str.<span class="hljs-keyword">length</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">            <span class="hljs-keyword">if</span> (str[i] <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> str[i<span class="hljs-operator"> - </span><span class="hljs-number">1</span>]) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">                currentCount<span class="hljs-operator">+</span><span class="hljs-operator">+</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">            } <span class="hljs-keyword">else</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">                <span class="hljs-keyword">if</span> (currentCount <span class="hljs-operator">&gt;</span> maxCount) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">                    maxCount <span class="hljs-operator">=</span> currentCount;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">                }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">                currentCount <span class="hljs-operator">=</span> <span class="hljs-number">1</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">            }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        <span class="hljs-operator">/</span><span class="hljs-operator">/</span> 最后一段连续字符的处理</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        <span class="hljs-keyword">if</span> (currentCount <span class="hljs-operator">&gt;</span> maxCount) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">            maxCount <span class="hljs-operator">=</span> currentCount;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        console.log(maxCount);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="32"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="33"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="34"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    doFunc();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="35"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="36"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:1,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:1,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t9"></a>计算A+B</h3> 
<p></p> 
<h4><a name="t10"></a>题目</h4> 
<div></div> 
<div></div> 
<div> 
 <img alt="" height="663" src="https://i-blog.csdnimg.cn/direct/edea7d43a4b04116a9095c4a74eaece1.png" width="1200"> 
</div> 
<div></div> 
<h4><a name="t11"></a>答案</h4> 
<pre data-index="2" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  <span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.trim().split(<span class="hljs-string">'\n'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  <span class="hljs-keyword">function</span> doFunc() {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    <span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> inputArray.<span class="hljs-keyword">length</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">      let nums <span class="hljs-operator">=</span> inputArray[i].split(<span class="hljs-string">' '</span>).map(<span class="hljs-keyword">Number</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">      <span class="hljs-keyword">if</span> (nums.<span class="hljs-keyword">length</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">2</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        let a <span class="hljs-operator">=</span> nums[<span class="hljs-number">0</span>];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        let b <span class="hljs-operator">=</span> nums[<span class="hljs-number">1</span>];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        let <span class="hljs-keyword">sum</span> <span class="hljs-operator">=</span> a <span class="hljs-operator">+</span> b;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        console.log(a);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        console.log(b);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        console.log(<span class="hljs-keyword">sum</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">      }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  doFunc();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">  process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:2,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:2,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t12"></a>计算英文句子的单词重量</h3> 
<p></p> 
<h4><a name="t13"></a>题目</h4> 
<p><img alt="" height="970" src="https://i-blog.csdnimg.cn/direct/bd8237b34fb54276964e96ec9752aacb.jpeg" width="1200"></p> 
<p></p> 
<h4><a name="t14"></a>答案</h4> 
<pre data-index="3" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    <span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">'\n'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    <span class="hljs-keyword">function</span> doFunc() {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        let <span class="hljs-keyword">sentence</span> <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">0</span>].trim();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        let words <span class="hljs-operator">=</span> <span class="hljs-keyword">sentence</span>.split(<span class="hljs-string">' '</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        let totalLength <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        <span class="hljs-keyword">for</span> (let word <span class="hljs-keyword">of</span> words) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">            totalLength <span class="hljs-operator">+</span><span class="hljs-operator">=</span> word.<span class="hljs-keyword">length</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        let averageLength <span class="hljs-operator">=</span> totalLength <span class="hljs-operator">/</span> words.<span class="hljs-keyword">length</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">        console.log(averageLength.toFixed(<span class="hljs-number">2</span>));</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    doFunc();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">    process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:3,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:3,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t15"></a><span style="color:#333333;"><strong>丢失的数</strong></span></h3> 
<p></p> 
<h4><a name="t16"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="1097" src="https://i-blog.csdnimg.cn/direct/b6962b719dff45a8bee3715322d138ba.png" width="1200"></p> 
<p></p> 
<h4><a name="t17"></a>答案</h4> 
<pre data-index="4" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">"utf8"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">""</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"data"</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"end"</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;let inputArr <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">function</span> doFunc(): <span class="hljs-keyword">boolean</span> | <span class="hljs-keyword">number</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let nums <span class="hljs-operator">=</span> inputArr[<span class="hljs-number">0</span>].split(<span class="hljs-string">" "</span>).map(<span class="hljs-keyword">Number</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;const n <span class="hljs-operator">=</span> nums.<span class="hljs-keyword">length</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;const <span class="hljs-keyword">set</span> <span class="hljs-operator">=</span> new <span class="hljs-keyword">Set</span><span class="hljs-operator">&lt;</span><span class="hljs-keyword">number</span><span class="hljs-operator">&gt;</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">for</span> (const num <span class="hljs-keyword">of</span> nums) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">set</span>.<span class="hljs-keyword">add</span>(num);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let <span class="hljs-keyword">count</span> <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let missingNum: <span class="hljs-keyword">number</span> | <span class="hljs-keyword">null</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">null</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">&nbsp;<span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> n; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (!<span class="hljs-keyword">set</span>.has(i)) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">count</span><span class="hljs-operator">+</span><span class="hljs-operator">+</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;missingNum <span class="hljs-operator">=</span> i;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (<span class="hljs-keyword">count</span> <span class="hljs-operator">&gt;</span> <span class="hljs-number">1</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> <span class="hljs-keyword">false</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">return</span> <span class="hljs-keyword">count</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">0</span> ? <span class="hljs-keyword">true</span> : missingNum!;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="32"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="33"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;const res <span class="hljs-operator">=</span> doFunc();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="34"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;console.log(res);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="35"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="36"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:4,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:4,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<p></p> 
<h3><a name="t18"></a><span style="color:#333333;"><strong>字母大小写转换</strong></span></h3> 
<p></p> 
<h4><a name="t19"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="495" src="https://i-blog.csdnimg.cn/direct/e6148ffb675642409b5d4c707cba2785.png" width="660"></p> 
<h4><a name="t20"></a>答案</h4> 
<pre data-index="5" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">"utf8"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">""</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"data"</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"end"</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;let inputArr <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-number">3</span>-查询<span class="hljs-operator">/</span>搜索插入位置</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">function</span> doFunc(): <span class="hljs-keyword">string</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">0</span>].trim()</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let result <span class="hljs-operator">=</span> <span class="hljs-string">""</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let <span class="hljs-keyword">length</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.<span class="hljs-keyword">length</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span><span class="hljs-number">0</span>;i<span class="hljs-operator">&lt;</span><span class="hljs-keyword">length</span>;i<span class="hljs-operator">+</span><span class="hljs-operator">+</span> ) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (<span class="hljs-string">"aeiouAEIOU"</span>.indexOf(<span class="hljs-keyword">input</span>[i])!<span class="hljs-operator">=</span><span class="hljs-operator">=</span> -<span class="hljs-number">1</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>[i].toUpperCase();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; } <span class="hljs-keyword">else</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>[i].toLowerCase();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">return</span> result;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">}</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;const res <span class="hljs-operator">=</span> doFunc();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;console.log(res);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:5,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:5,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t21"></a><span style="color:#333333;"><strong>查询</strong></span><span style="color:#333333;"><strong>插入位置</strong></span></h3> 
<h4><a name="t22"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="480" src="https://i-blog.csdnimg.cn/direct/b5fb084d0d8343cfbd27d8ce973f2e54.png" width="667"></p> 
<p></p> 
<h4><a name="t23"></a>答案</h4> 
<pre data-index="6" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">"utf8"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">""</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"data"</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"end"</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;let inputArr <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">function</span> doFunc(): <span class="hljs-keyword">number</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let nums <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">0</span>].split(<span class="hljs-string">' '</span>).map(<span class="hljs-keyword">Number</span>)</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let target:<span class="hljs-keyword">number</span> <span class="hljs-operator">=</span> nums.pop()!</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;while(nums[Math.floor(nums.<span class="hljs-keyword">length</span> <span class="hljs-operator">/</span> <span class="hljs-number">2</span>)] <span class="hljs-operator">&gt;</span> target) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;nums <span class="hljs-operator">=</span> nums.slice(<span class="hljs-number">0</span>, Math.floor(nums.<span class="hljs-keyword">length</span> <span class="hljs-operator">/</span> <span class="hljs-number">2</span>));</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">for</span>(let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> nums.<span class="hljs-keyword">length</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span>(nums[i] <span class="hljs-operator">&gt;=</span> target) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> i;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">return</span> nums.<span class="hljs-keyword">length</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> };</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;let result <span class="hljs-operator">=</span> doFunc();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;console.log(result);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:6,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:6,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t24"></a><span style="color:#333333;"><strong>最长元音字串的长度</strong></span></h3> 
<h4><a name="t25"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="1200" src="https://i-blog.csdnimg.cn/direct/5e35fca7587640278f9c5461dc35e190.png" width="1200"></p> 
<p></p> 
<h4><a name="t26"></a>答案</h4> 
<pre data-index="7" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">"utf8"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">""</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"data"</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"end"</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;let inputString <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">0</span>]</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">function</span> doFunc(s:<span class="hljs-keyword">string</span>): <span class="hljs-keyword">number</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let maxLength <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let currentLength <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;const vowels <span class="hljs-operator">=</span> new <span class="hljs-keyword">Set</span>([<span class="hljs-string">'a'</span>, <span class="hljs-string">'e'</span>, <span class="hljs-string">'i'</span>, <span class="hljs-string">'o'</span>, <span class="hljs-string">'u'</span>, <span class="hljs-string">'A'</span>, <span class="hljs-string">'E'</span>, <span class="hljs-string">'I'</span>, <span class="hljs-string">'O'</span>, <span class="hljs-string">'U'</span>]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> s.<span class="hljs-keyword">length</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (vowels.has(s.charAt(i))) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;currentLength<span class="hljs-operator">+</span><span class="hljs-operator">+</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;maxLength <span class="hljs-operator">=</span> Math.max(maxLength, currentLength);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; } <span class="hljs-keyword">else</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;currentLength <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">return</span> maxLength;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> };</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">&nbsp;let result <span class="hljs-operator">=</span> doFunc(inputString);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;console.log(result);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:7,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:7,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t27"></a><span style="color:#333333;"><strong>N</strong></span><span style="color:#333333;"><strong>整数阶乘</strong></span></h3> 
<h4><a name="t28"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="827" src="https://i-blog.csdnimg.cn/direct/6282347835a84b8787773a017a0054e7.png" width="1200"></p> 
<h4><a name="t29"></a>答案</h4> 
<pre data-index="8" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">"utf8"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">""</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"data"</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"end"</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;let inputNum <span class="hljs-operator">=</span> parseInt(<span class="hljs-keyword">input</span>,<span class="hljs-number">10</span>)</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">function</span> factorial(N: <span class="hljs-keyword">number</span>): bigint {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">if</span> (N <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">0</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> BigInt(<span class="hljs-number">1</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">return</span> BigInt(N) <span class="hljs-operator">*</span> factorial(N<span class="hljs-operator"> - </span><span class="hljs-number">1</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">}</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-keyword">if</span> (inputNum <span class="hljs-operator">&gt;=</span> <span class="hljs-number">0</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> inputNum <span class="hljs-operator">&lt;=</span> <span class="hljs-number">1000</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;const result <span class="hljs-operator">=</span> factorial(inputNum).toString();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;console.log(result);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">} <span class="hljs-keyword">else</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;console.log(<span class="hljs-string">'输入的整数不符合要求'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">}</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:8,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:8,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t30"></a><span style="color:#333333;"><strong>最大公因数</strong></span></h3> 
<h4><a name="t31"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="1020" src="https://i-blog.csdnimg.cn/direct/7bd691eabc724f3587c24baab465bb96.png" width="1200"></p> 
<h4><a name="t32"></a>答案</h4> 
<pre data-index="9" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">"utf8"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">""</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"data"</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"end"</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> const a <span class="hljs-operator">=</span> <span class="hljs-keyword">Number</span>(inputArray.toString().split(<span class="hljs-string">" "</span>)[<span class="hljs-number">0</span>])</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> const b<span class="hljs-operator">=</span> <span class="hljs-keyword">Number</span>(inputArray.toString().split(<span class="hljs-string">" "</span>)[<span class="hljs-number">1</span>])</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-keyword">function</span> doFunc(a: <span class="hljs-keyword">number</span>, b: <span class="hljs-keyword">number</span>): <span class="hljs-keyword">number</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; while (b!<span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">0</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; let temp <span class="hljs-operator">=</span> b;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; b <span class="hljs-operator">=</span> a % b;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a <span class="hljs-operator">=</span> temp;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; <span class="hljs-keyword">return</span> a;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let result <span class="hljs-operator">=</span> doFunc(a, b);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> console.log(result);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:9,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:9,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t33"></a><span style="color:#333333;"><strong>与后续更小值之差</strong></span></h3> 
<h4><a name="t34"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="1137" src="https://i-blog.csdnimg.cn/direct/62ce375c8cae4c61b30aecccabf9624c.png" width="1200"></p> 
<h4><a name="t35"></a>答案</h4> 
<pre data-index="10" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">"utf8"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">""</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"data"</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">"end"</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-keyword">function</span> doFunc():<span class="hljs-keyword">string</span>{</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let nums: <span class="hljs-keyword">number</span>[] <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">0</span>].split(<span class="hljs-string">' '</span>).map(<span class="hljs-keyword">Number</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let result: <span class="hljs-keyword">number</span>[] <span class="hljs-operator">=</span> [];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> nums.<span class="hljs-keyword">length</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let foundSmaller <span class="hljs-operator">=</span> <span class="hljs-keyword">false</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let j <span class="hljs-operator">=</span> i <span class="hljs-operator">+</span> <span class="hljs-number">1</span>; j <span class="hljs-operator">&lt;</span> nums.<span class="hljs-keyword">length</span>; j<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (nums[j] <span class="hljs-operator">&lt;</span> nums[i]) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result.push(nums[i]<span class="hljs-operator"> - </span>nums[j]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foundSmaller <span class="hljs-operator">=</span> <span class="hljs-keyword">true</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (!foundSmaller) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result.push(nums[i]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">return</span> result.map(<span class="hljs-keyword">String</span>).join(<span class="hljs-string">' '</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;let res <span class="hljs-operator">=</span> doFunc()</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="32"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;console.log(res)</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="33"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="34"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:10,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:10,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t36"></a><span style="color:#333333;"><strong>整数分解</strong></span></h3> 
<h4><a name="t37"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="658" src="https://i-blog.csdnimg.cn/direct/b00693ed154147449b127bde906fc0de.png" width="1200"></p> 
<p></p> 
<h4><a name="t38"></a>答案</h4> 
<pre data-index="11" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">'\n'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let c <span class="hljs-operator">=</span> parseInt(inputArray[<span class="hljs-number">0</span>]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">function</span> integerFactorization(n: <span class="hljs-keyword">number</span>): <span class="hljs-keyword">number</span>[] {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let factors: <span class="hljs-keyword">number</span>[] <span class="hljs-operator">=</span> [];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let i: <span class="hljs-keyword">number</span> <span class="hljs-operator">=</span> <span class="hljs-number">2</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;while (n <span class="hljs-operator">&gt;</span> <span class="hljs-number">1</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while (n % i <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">0</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;factors.push(i);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;n <span class="hljs-operator">/</span><span class="hljs-operator">=</span> i;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> factors;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let result: <span class="hljs-keyword">number</span>[] <span class="hljs-operator">=</span> integerFactorization(c);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;console.log(result.join(<span class="hljs-string">" "</span>));</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:11,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:11,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t39"></a><span style="color:#333333;"><strong>计算可用的号码数量</strong></span></h3> 
<h4><a name="t40"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="970" src="https://i-blog.csdnimg.cn/direct/99d668245bde4ebc983d17864361debc.png" width="1200"></p> 
<p></p> 
<h4><a name="t41"></a>答案</h4> 
<pre data-index="12" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> const <span class="hljs-keyword">start</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">Number</span>(inputArray.toString().split(<span class="hljs-string">" "</span>)[<span class="hljs-number">0</span>])</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> const <span class="hljs-keyword">end</span><span class="hljs-operator">=</span> <span class="hljs-keyword">Number</span>(inputArray.toString().split(<span class="hljs-string">" "</span>)[<span class="hljs-number">1</span>])</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-keyword">function</span> doFunc(<span class="hljs-keyword">start</span>: <span class="hljs-keyword">number</span>, <span class="hljs-keyword">end</span>: <span class="hljs-keyword">number</span>): <span class="hljs-keyword">number</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; let <span class="hljs-keyword">count</span> <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; <span class="hljs-keyword">for</span> (let num <span class="hljs-operator">=</span> <span class="hljs-keyword">start</span>; num <span class="hljs-operator">&lt;=</span> <span class="hljs-keyword">end</span>; num<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; let numStr <span class="hljs-operator">=</span> num.toString();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; <span class="hljs-keyword">if</span> (numStr.indexOf(<span class="hljs-string">'4'</span>) <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> -<span class="hljs-number">1</span> <span class="hljs-operator">&amp;</span><span class="hljs-operator">&amp;</span> numStr.indexOf(<span class="hljs-string">'18'</span>) <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> -<span class="hljs-number">1</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="hljs-keyword">count</span><span class="hljs-operator">+</span><span class="hljs-operator">+</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; <span class="hljs-keyword">return</span> <span class="hljs-keyword">count</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let result <span class="hljs-operator">=</span> doFunc(<span class="hljs-keyword">start</span>, <span class="hljs-keyword">end</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> console.log(result);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:12,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:12,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<h3><a name="t42"></a><span style="color:#333333;"><strong>字符串相等</strong></span></h3> 
<h4><a name="t43"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="960" src="https://i-blog.csdnimg.cn/direct/744fbdfd432e48648ec719ad6760d89e.png" width="1200"></p> 
<h4><a name="t44"></a>答案</h4> 
<pre data-index="13" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let s<span class="hljs-number">1</span> <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">0</span>]</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let s<span class="hljs-number">2</span> <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">1</span>]</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-keyword">function</span> areEqualAfterProcess(s<span class="hljs-number">1</span>:<span class="hljs-keyword">string</span>,s<span class="hljs-number">2</span>:<span class="hljs-keyword">string</span>): <span class="hljs-keyword">string</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; let processedS<span class="hljs-number">1</span> <span class="hljs-operator">=</span> s<span class="hljs-number">1</span>.<span class="hljs-keyword">replace</span>(<span class="hljs-operator">/</span>\s<span class="hljs-operator">/</span>g, <span class="hljs-string">""</span>).toLowerCase();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; let processedS<span class="hljs-number">2</span> <span class="hljs-operator">=</span> s<span class="hljs-number">2</span>.<span class="hljs-keyword">replace</span>(<span class="hljs-operator">/</span>\s<span class="hljs-operator">/</span>g, <span class="hljs-string">""</span>).toLowerCase();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; <span class="hljs-keyword">return</span> processedS<span class="hljs-number">1</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> processedS<span class="hljs-number">2</span>?<span class="hljs-string">"Yes"</span>:<span class="hljs-string">"No"</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let result <span class="hljs-operator">=</span> areEqualAfterProcess(s<span class="hljs-number">1</span>, s<span class="hljs-number">2</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> console.log(result);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:13,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:13,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t45"></a><span style="color:#333333;"><strong>字符串大小写转换</strong></span></h3> 
<h4><a name="t46"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="1200" src="https://i-blog.csdnimg.cn/direct/a5f2bdf91df44f3b88da7e3f384d314c.png" width="1200"></p> 
<h4><a name="t47"></a>答案</h4> 
<pre data-index="14" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">/</span>let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-keyword">function</span> convertString(<span class="hljs-keyword">input</span>: <span class="hljs-keyword">string</span>): <span class="hljs-keyword">string</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let <span class="hljs-keyword">index</span>:<span class="hljs-keyword">number</span> <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; let result:<span class="hljs-keyword">string</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; const vowels <span class="hljs-operator">=</span> [<span class="hljs-string">'a'</span>, <span class="hljs-string">'e'</span>, <span class="hljs-string">'i'</span>, <span class="hljs-string">'o'</span>, <span class="hljs-string">'u'</span>, <span class="hljs-string">'A'</span>, <span class="hljs-string">'E'</span>, <span class="hljs-string">'I'</span>, <span class="hljs-string">'O'</span>, <span class="hljs-string">'U'</span>];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; while(<span class="hljs-keyword">index</span><span class="hljs-operator">&lt;</span><span class="hljs-keyword">input</span>.<span class="hljs-keyword">length</span>){</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; let char:<span class="hljs-keyword">string</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.charAt(<span class="hljs-keyword">index</span>)</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; <span class="hljs-keyword">if</span>(vowels.includes(char)){</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span class="hljs-operator">+</span><span class="hljs-operator">=</span> char.toUpperCase()</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }<span class="hljs-keyword">else</span>{</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span class="hljs-operator">+</span><span class="hljs-operator">=</span> char.toLowerCase()</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; <span class="hljs-keyword">index</span><span class="hljs-operator">+</span><span class="hljs-operator">+</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; <span class="hljs-keyword">return</span> result</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let result <span class="hljs-operator">=</span> convertString(<span class="hljs-keyword">input</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> console.log(result);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:14,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:14,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<h3><a name="t48"></a><span style="color:#333333;"><strong>下一个更大值</strong></span></h3> 
<h4><a name="t49"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="1200" src="https://i-blog.csdnimg.cn/direct/1eb60cb850814066b326b21fabf21995.png" width="1200"></p> 
<h4><a name="t50"></a>答案</h4> 
<pre data-index="15" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">/</span>let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> <span class="hljs-keyword">function</span> doFunc(nums: <span class="hljs-keyword">string</span>): <span class="hljs-keyword">string</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let numArray: <span class="hljs-keyword">number</span>[] <span class="hljs-operator">=</span> nums.split(<span class="hljs-string">' '</span>).map(<span class="hljs-keyword">Number</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let result: <span class="hljs-keyword">number</span>[] <span class="hljs-operator">=</span> [];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> numArray.<span class="hljs-keyword">length</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;let foundNextGreater <span class="hljs-operator">=</span> <span class="hljs-keyword">false</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let j <span class="hljs-operator">=</span> i <span class="hljs-operator">+</span> <span class="hljs-number">1</span>; j <span class="hljs-operator">&lt;</span> numArray.<span class="hljs-keyword">length</span>; j<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (numArray[j] <span class="hljs-operator">&gt;</span> numArray[i]) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result.push(j<span class="hljs-operator"> - </span>i);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;foundNextGreater <span class="hljs-operator">=</span> <span class="hljs-keyword">true</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (!foundNextGreater) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result.push(<span class="hljs-number">0</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> result.map(<span class="hljs-keyword">String</span>).join(<span class="hljs-string">' '</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let <span class="hljs-keyword">output</span> <span class="hljs-operator">=</span> doFunc(<span class="hljs-keyword">input</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="32"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> console.log(<span class="hljs-keyword">output</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="33"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">&nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="34"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:15,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:15,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h3><a name="t51"></a><span style="color:#333333;"><strong>超大数相加</strong></span></h3> 
<h4><a name="t52"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="1180" src="https://i-blog.csdnimg.cn/direct/e6910be4b6ab49a2bdc5101da6227f61.png" width="1200"></p> 
<h4><a name="t53"></a>答案</h4> 
<pre data-index="16" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let num<span class="hljs-number">1</span> <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">0</span>]</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let num<span class="hljs-number">2</span> <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">1</span>]</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">function</span> addBigNumbers(num<span class="hljs-number">1</span>: <span class="hljs-keyword">string</span>, num<span class="hljs-number">2</span>: <span class="hljs-keyword">string</span>): <span class="hljs-keyword">string</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let i <span class="hljs-operator">=</span> num<span class="hljs-number">1</span>.<span class="hljs-keyword">length</span><span class="hljs-operator"> - </span><span class="hljs-number">1</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let j <span class="hljs-operator">=</span> num<span class="hljs-number">2</span>.<span class="hljs-keyword">length</span><span class="hljs-operator"> - </span><span class="hljs-number">1</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let carry <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; <span class="hljs-operator">/</span><span class="hljs-operator">/</span> 进位</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let result <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;while (i <span class="hljs-operator">&gt;=</span> <span class="hljs-number">0</span> || j <span class="hljs-operator">&gt;=</span> <span class="hljs-number">0</span> || carry <span class="hljs-operator">&gt;</span> <span class="hljs-number">0</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const digit<span class="hljs-number">1</span> <span class="hljs-operator">=</span> i <span class="hljs-operator">&gt;=</span> <span class="hljs-number">0</span>? parseInt(num<span class="hljs-number">1</span>.charAt(i), <span class="hljs-number">10</span>) : <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const digit<span class="hljs-number">2</span> <span class="hljs-operator">=</span> j <span class="hljs-operator">&gt;=</span> <span class="hljs-number">0</span>? parseInt(num<span class="hljs-number">2</span>.charAt(j), <span class="hljs-number">10</span>) : <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;const <span class="hljs-keyword">sum</span> <span class="hljs-operator">=</span> digit<span class="hljs-number">1</span> <span class="hljs-operator">+</span> digit<span class="hljs-number">2</span> <span class="hljs-operator">+</span> carry;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;result <span class="hljs-operator">=</span> (<span class="hljs-keyword">sum</span> % <span class="hljs-number">10</span>).toString() <span class="hljs-operator">+</span> result;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;carry <span class="hljs-operator">=</span> Math.floor(<span class="hljs-keyword">sum</span> <span class="hljs-operator">/</span> <span class="hljs-number">10</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;i--;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;j--;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> result;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let <span class="hljs-keyword">sum</span> <span class="hljs-operator">=</span> addBigNumbers(num<span class="hljs-number">1</span>,num<span class="hljs-number">2</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="32"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> console.log(<span class="hljs-keyword">sum</span>); </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="33"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="34"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:16,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:16,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<h3><a name="t54"></a><span style="color:#333333;"><strong>平方数之和</strong></span></h3> 
<h4><a name="t55"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="1200" src="https://i-blog.csdnimg.cn/direct/4976241528ab45a78ad7e4b84f3dcd3b.png" width="1200"></p> 
<h4><a name="t56"></a>答案</h4> 
<pre data-index="17" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">/</span>let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">"\n"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;<span class="hljs-operator">/</span><span class="hljs-operator">*</span> </div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; 待实现函数，在此函数中填入答题代码</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; doFunc（））</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"><span class="hljs-comment"> */</span></div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">'\n'</span>)</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> let n <span class="hljs-operator">=</span> <span class="hljs-keyword">Number</span>(inputArray[<span class="hljs-number">0</span>].split(<span class="hljs-string">''</span>))</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">function</span> doFunc(n: <span class="hljs-keyword">number</span>): <span class="hljs-keyword">string</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let a <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; a <span class="hljs-operator">*</span> a <span class="hljs-operator">&lt;=</span> n; a<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let b <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; b <span class="hljs-operator">*</span> b <span class="hljs-operator">&lt;=</span> n; b<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (a <span class="hljs-operator">*</span> a <span class="hljs-operator">+</span> b <span class="hljs-operator">*</span> b <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> n) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> <span class="hljs-string">"TRUE"</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> <span class="hljs-string">"FALSE"</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let result <span class="hljs-operator">=</span> doFunc(n);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;console.log(result);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:17,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:17,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<h3><a name="t57"></a><span style="color:#333333;"><strong>服务器集群网络延迟</strong></span></h3> 
<h4><a name="t58"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="500" src="https://i-blog.csdnimg.cn/direct/02d3572d147645c1aa6a53d5fef88b25.png" width="761"></p> 
<p></p> 
<h4><a name="t59"></a>答案</h4> 
<pre data-index="18" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">'\n'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">if</span> (inputArray.<span class="hljs-keyword">length</span> <span class="hljs-operator">&lt;</span> <span class="hljs-number">2</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;console.<span class="hljs-keyword">error</span>(<span class="hljs-string">"输入数据不完整"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">function</span> doFunc() {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let minDelay <span class="hljs-operator">=</span> Infinity;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let n <span class="hljs-operator">=</span> parseInt(inputArray[<span class="hljs-number">0</span>]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (n <span class="hljs-operator">&lt;</span> <span class="hljs-number">1</span> || n <span class="hljs-operator">&gt;</span> <span class="hljs-number">5001</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.<span class="hljs-keyword">error</span>(<span class="hljs-string">"输入的数组元素个数超出范围"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let numbers <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">1</span>].split(<span class="hljs-string">' '</span>).map(<span class="hljs-keyword">Number</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let num <span class="hljs-keyword">of</span> numbers) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (num <span class="hljs-operator">&lt;</span> <span class="hljs-number">1</span> || num <span class="hljs-operator">&lt;</span> <span class="hljs-number">1</span> || num <span class="hljs-operator">&gt;</span> <span class="hljs-number">10000</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.<span class="hljs-keyword">error</span>(<span class="hljs-string">"输入的数组元素值超出范围"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (numbers.<span class="hljs-keyword">length</span>!<span class="hljs-operator">=</span><span class="hljs-operator">=</span> n) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.<span class="hljs-keyword">error</span>(<span class="hljs-string">"输入的数组元素个数与第一行声明的不符"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> n; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="32"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">&nbsp; &nbsp;    let currentDelay <span class="hljs-operator">=</span> <span class="hljs-number">0</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="33"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let j <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; j <span class="hljs-operator">&lt;</span> n; j<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="34"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;currentDelay <span class="hljs-operator">+</span><span class="hljs-operator">=</span> Math.abs(numbers[i]<span class="hljs-operator"> - </span>numbers[j]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="35"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="36"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (currentDelay <span class="hljs-operator">&lt;</span> minDelay) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="37"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;minDelay <span class="hljs-operator">=</span> currentDelay;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="38"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="39"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="40"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;console.log(minDelay);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="41"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="42"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;doFunc();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="43"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="44"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:18,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:18,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<h3 style="background-color:transparent;"><a name="t60"></a><span style="color:#333333;"><strong>查找新增字母</strong></span></h3> 
<h4><a name="t61"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="1200" src="https://i-blog.csdnimg.cn/direct/d1ccc1347f5648c8b2dbbd4c3bbf8a61.png" width="1200"></p> 
<p></p> 
<h4><a name="t62"></a>答案</h4> 
<pre data-index="19" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">'\n'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">function</span> findAddedLetter(a: <span class="hljs-keyword">string</span>, b: <span class="hljs-keyword">string</span>): <span class="hljs-keyword">string</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let charCountA: { [<span class="hljs-keyword">key</span>: <span class="hljs-keyword">string</span>]: <span class="hljs-keyword">number</span> } <span class="hljs-operator">=</span> {};</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let charCountB: { [<span class="hljs-keyword">key</span>: <span class="hljs-keyword">string</span>]: <span class="hljs-keyword">number</span> } <span class="hljs-operator">=</span> {};</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let char <span class="hljs-keyword">of</span> a) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">&nbsp;<span class="hljs-keyword">if</span> (charCountA[char]) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;charCountA[char]<span class="hljs-operator">+</span><span class="hljs-operator">+</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <span class="hljs-keyword">else</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;charCountA[char] <span class="hljs-operator">=</span> <span class="hljs-number">1</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let char <span class="hljs-keyword">of</span> b) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (charCountB[char]) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;charCountB[char]<span class="hljs-operator">+</span><span class="hljs-operator">+</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <span class="hljs-keyword">else</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;charCountB[char] <span class="hljs-operator">=</span> <span class="hljs-number">1</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let char <span class="hljs-keyword">in</span> charCountB) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (!charCountA[char] || charCountB[char] <span class="hljs-operator">&gt;</span> charCountA[char]) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> char;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="31"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="32"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> <span class="hljs-string">""</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="33"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="34"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">function</span> main() {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="35"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">"y"</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="36"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;let parts <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">" "</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="37"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (parts.<span class="hljs-keyword">length</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span>) <span class="hljs-keyword">return</span> console.log(<span class="hljs-keyword">input</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="38"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (parts.<span class="hljs-keyword">length</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">2</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="39"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;let addedLetter <span class="hljs-operator">=</span> findAddedLetter(parts[<span class="hljs-number">0</span>], parts[<span class="hljs-number">1</span>]);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="40"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.log(<span class="hljs-string">"添加的字母是: "</span> <span class="hljs-operator">+</span> addedLetter);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="41"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; } <span class="hljs-keyword">else</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="42"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.log(<span class="hljs-string">"输入的格式不符合要求"</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="43"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="44"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="45"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;main();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="46"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="47"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:19,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:19,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<h3><a name="t63"></a><span style="color:#333333;"><strong>寻找相同子串</strong></span></h3> 
<h4><a name="t64"></a><span style="color:#333333;"><strong>题目</strong></span></h4> 
<p><img alt="" height="936" src="https://i-blog.csdnimg.cn/direct/52e25f326c114201a874c7776f9dfc1d.png" width="1035"></p> 
<p></p> 
<h4><a name="t65"></a>答案</h4> 
<pre data-index="20" class="set-code-show" name="code" style="user-select: auto;"><code class="hljs language-cobol" style="user-select: auto;"><ol class="hljs-ln" style="width:100%"><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="1"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">resume</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="2"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.setEncoding(<span class="hljs-string">'utf-8'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="3"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">let <span class="hljs-keyword">input</span> <span class="hljs-operator">=</span> <span class="hljs-string">''</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="4"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'data'</span>, (<span class="hljs-keyword">data</span>) <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="5"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">input</span> <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-keyword">data</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="6"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="7"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">process.stdin.<span class="hljs-keyword">on</span>(<span class="hljs-string">'end'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="8"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;let inputArray <span class="hljs-operator">=</span> <span class="hljs-keyword">input</span>.split(<span class="hljs-string">'\n'</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="9"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;const text <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">0</span>];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="10"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> const pattern <span class="hljs-operator">=</span> inputArray[<span class="hljs-number">1</span>];</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="11"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;<span class="hljs-keyword">function</span> strStr(t: <span class="hljs-keyword">string</span>, p: <span class="hljs-keyword">string</span>): <span class="hljs-keyword">number</span>|<span class="hljs-keyword">string</span> {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="12"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;const tLength <span class="hljs-operator">=</span> t.<span class="hljs-keyword">length</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="13"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;const pLength <span class="hljs-operator">=</span> p.<span class="hljs-keyword">length</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="14"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (let i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;=</span> tLength<span class="hljs-operator"> - </span>pLength; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="15"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;let j;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="16"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">for</span> (j <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; j <span class="hljs-operator">&lt;</span> pLength; j<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="17"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (t[i <span class="hljs-operator">+</span> j]!<span class="hljs-operator">=</span><span class="hljs-operator">=</span> p[j]) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="18"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="19"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="20"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="21"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">if</span> (j <span class="hljs-operator">=</span><span class="hljs-operator">=</span><span class="hljs-operator">=</span> pLength) {</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="22"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="hljs-keyword">return</span> i<span class="hljs-operator">+</span><span class="hljs-number">1</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="23"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="24"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp; &nbsp; }</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="25"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; <span class="hljs-keyword">return</span> <span class="hljs-string">"No"</span>;</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="26"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">}</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="27"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> const <span class="hljs-keyword">index</span> <span class="hljs-operator">=</span> strStr(text, pattern);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="28"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> &nbsp; &nbsp;console.log(<span class="hljs-keyword">index</span>);</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="29"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line"> process.<span class="hljs-keyword">exit</span>();</div></div></li><li><div class="hljs-ln-numbers"><div class="hljs-ln-line hljs-ln-n" data-line-number="30"></div></div><div class="hljs-ln-code"><div class="hljs-ln-line">});</div></div></li></ol></code><div class="hljs-button {2} add_def" data-title="复制" onclick="hljs.copyCode(event)"></div><button class="btn-code-notes ckeditor" data-report-view="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:20,&quot;runIdx&quot;:-1}}" data-report-click="{&quot;spm&quot;:&quot;3001.10436&quot;,&quot;extra&quot;:{&quot;index&quot;:20,&quot;runIdx&quot;:-1}}">代码解读</button></pre> 
<p></p> 
<h2 id="%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9"><a name="t66"></a>注意事项</h2> 
<p></p> 
<p>当前<a href="https://so.csdn.net/so/search?q=%E7%BC%96%E7%A8%8B%E9%A2%98&amp;spm=1001.2101.3001.7020" target="_blank" class="hl hl-1" data-report-view="{&quot;spm&quot;:&quot;1001.2101.3001.7020&quot;,&quot;dest&quot;:&quot;https://so.csdn.net/so/search?q=%E7%BC%96%E7%A8%8B%E9%A2%98&amp;spm=1001.2101.3001.7020&quot;,&quot;extra&quot;:&quot;{\&quot;searchword\&quot;:\&quot;编程题\&quot;}&quot;}" data-report-click="{&quot;spm&quot;:&quot;1001.2101.3001.7020&quot;,&quot;dest&quot;:&quot;https://so.csdn.net/so/search?q=%E7%BC%96%E7%A8%8B%E9%A2%98&amp;spm=1001.2101.3001.7020&quot;,&quot;extra&quot;:&quot;{\&quot;searchword\&quot;:\&quot;编程题\&quot;}&quot;}" data-tit="编程题" data-pretit="编程题">编程题</a>答案部分是博主创建的鸿蒙next学习交流群里面一个群友提供的答案，他是满分通过的</p> 
<p>大家注意如果有其他新的编程题可以让大<span class="words-blog hl-git-1" data-report-view="{&quot;spm&quot;:&quot;1001.2101.3001.10283&quot;,&quot;extra&quot;:&quot;{\&quot;words\&quot;:\&quot;模型\&quot;}&quot;}" data-tit="模型" data-pretit="模型">模型</span>做，比如chatgpt</p> 
<p></p> 
<p></p>
                